package pl.edu.uj.tcs.blef.protocol;

/**
 * Client-Server protocol request /identify factory.
 * @author Maciej Bendkowski
 *
 */
public final class IdentifyRequestFactory implements RequestFactory {

	@Override
	public Request build(Object[] parameters, RequestHandler handler) throws BuildFailedException {
		if(parameters != null) throw new BuildFailedException("No arguments expected.");
		return new IdentifyRequest("/identify", handler);
	}

	@Override
	public Request parse(String message, RequestHandler handler) throws ParseFailedException, BuildFailedException {
		if(message.split(" ").length != 1) throw new ParseFailedException("Unknown request.");
		else if("/identify".equals(message.split(" ")[0])) return build(null, handler);
		else throw new ParseFailedException("Unknown request.");
	}

}
